package com.dailygreetings.dailygreetings.task;

import com.dailygreetings.dailygreetings.service.DailyGreetingService;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @BelongsProject: daily-greetings
 * @BelongsPackage: com.dailygreetings.dailygreetings.task
 * @Author: shanzhengfei
 * @CreateTime: 2024-11-21  17:57
 * @Description: 每日定时
 * @Version: 1.0
 */
@Log4j2
@AllArgsConstructor
@Component
public class WechatTask {

    private DailyGreetingService service;

    /**
     * 每天早上8点执行
     */
    @Scheduled(cron = "0 0 8 * * ?")
    public void sendDailyMessage() {
        log.info("===== 开始发送每日早安 =====");
        service.sendDailyGreeting();
        log.info("===== 每日早安发送完成 =====");
    }
}
